package com.infitecs.eyas.mill.service;

import com.infitecs.eyas.mill.dao.MillDao;
import com.infitecs.eyas.mill.model.Mill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author panzhuowen
 * @version 1.0.1
 */
@Service
public class MillService {

    @Autowired
    private MillDao millDao;

    public Mill getMill(Double baseOutput, int E7) {
        Mill millRes = null;
        Mill mill = new Mill();
        mill.setBaseOutput(baseOutput);
        switch (E7) {
            case 1:
                millRes = millDao.getMps(mill);
                break;
            case 2:
                millRes = millDao.getMp(mill);
                break;
            case 3:
                millRes = millDao.getZgm(mill);
                break;
            case 4:
                millRes = millDao.getZgmI(mill);
                break;
            case 5:
                millRes = millDao.getZgmII(mill);
                break;
            case 6:
                millRes = millDao.getZgmIII(mill);
                break;
            case 7:
                millRes = millDao.getMpsHpII(mill);
                break;
            case 8:
                millRes = millDao.getHp(mill);
                break;
            case 9:
                millRes = millDao.getE(mill);
                break;
        }
        return millRes;
    }

    public Mill getMill(String model, int E7) {
        Mill millRes = null;
        Mill mill = new Mill();
        mill.setModel(model);
        switch (E7) {
            case 1:
                millRes = millDao.getMps(mill);
                break;
            case 2:
                millRes = millDao.getMp(mill);
                break;
            case 3:
                millRes = millDao.getZgm(mill);
                break;
            case 4:
                millRes = millDao.getZgmI(mill);
                break;
            case 5:
                millRes = millDao.getZgmII(mill);
                break;
            case 6:
                millRes = millDao.getZgmIII(mill);
                break;
            case 7:
                millRes = millDao.getMpsHpII(mill);
                break;
            case 8:
                millRes = millDao.getHp(mill);
                break;
            case 9:
                millRes = millDao.getE(mill);
                break;
        }
        return millRes;
    }

    public List<Mill> getMillList(int E7) {
        String tableName="";
        switch (E7) {
             case 1:
                 tableName = "mill_mps";
                 break;
             case 2:
                 tableName = "baseOutput";
                 break;
             case 3:
                 tableName = "mill_zgm";
                 break;
             case 4:
                 tableName = "mill_zgm_i";
                 break;
             case 5:
                 tableName = "mill_zgm_ii";
                 break;
             case 6:
                 tableName = "mill_zgm_iii";
                 break;
             case 7:
                 tableName = "mill_mps_hp_ii";
                 break;
             case 8:
                 tableName = "mill_hp";
                 break;
             case 9:
                 tableName = "mill_e";
                 break;
         }
        Mill mill =new Mill();
        mill.setModel(tableName);
        return  millDao.getMillList(mill);
    }

}
